public class BruteForceSolution {
    public String minWindow(String s, String t) {
        int sLen = s.length();
        int tLen = t.length();
        int[] tArr = new int[128];
        int min = sLen + 1;
        int index = 0;
        for (int i = 0; i < tLen; i++) {
            char ch = t.charAt(i);
            tArr[ch]++;
        }
        for (int i = 0; i < sLen; i++) {
            int[] sArr = new int[128];
            int count = 0;//记录是不是有效字符
            for (int j = i; j < sLen; j++) {
                char ch = s.charAt(j);
                sArr[ch]++;
                if (sArr[ch] <= tArr[ch]) {
                    count++;//是有效字符
                }
                if (count == tLen) {
                    if (min > j - i + 1) {
                        min = j - i + 1;
                        index = i;//记录有效字符串的下标
                    }
                    break;
                }
            }
        }
        return min == sLen + 1 ? "" : s.substring(index, index + min);
    }
}
